From eb0e4c0b1180b63be74fda649d5f4994b0955199 Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Sun, 29 Jan 2017 17:55:47 -0500 Subject: [PATCH] Add a test for stable metadata across workspaces --- tests/build.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/build.rs b/tests/build.rs index f2081c61f..f096b8fbd 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1,4 +1,5 @@ extern crate cargo; +#[macro_use] extern crate cargotest; extern crate hamcrest; extern crate tempdir; @@ -3271,3 +3272,32 @@ fn no_bin_in_src_with_lib() { execs().with_status(101) .with_stderr_contains(r#"[ERROR] couldn't read "[..]main.rs"[..]"#)); } + +#[test] +fn same_metadata_different_directory() { + // A top-level crate built in two different workspaces should have the + // same metadata hash. + let p = project("foo1") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])); + let output = t!(String::from_utf8( + t!(p.cargo_process("build").arg("-v").exec_with_output()) + .stderr, + )); + let metadata = output + .split_whitespace() + .filter(|arg| arg.starts_with("metadata=")) + .next() + .unwrap(); + + let p = project("foo2") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])); + + assert_that( + p.cargo_process("build").arg("-v"), + execs().with_status(0).with_stderr_contains( + format!("[..]{}[..]", metadata), + ), + ); +} -- 2.30.2